package com.p7.notepad.app;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tools.s7.base.CompatFragment;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/5/6.
 */
public abstract class BaseFragment extends CompatFragment {

    private View fView;

    protected Unbinder unbinder;

    public abstract int getLayoutId();

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (fView == null) {
            fView = inflater.inflate(getLayoutId(), container, false);
            unbinder = ButterKnife.bind(this, fView);
            initEvents();
        }
        initEvents();

        return fView;
    }

    protected void initEvents() {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (unbinder != null) {
            unbinder.unbind();
        }
    }

}
